import '../bean/BleBeanInterface.dart';
import '../send/SendInterface.dart';

///检测扫描到的蓝牙是否是兼容的
abstract class CheckBleSupportInterface {
  ///检测扫描到的蓝牙是否是兼容的
  /// @param bean 扫描到的蓝牙信息
  BleBeanInterface? isSupport(BleBeanInterface bean);

  ///获取匹配的数据
  static List getMatchData(List scanData, List matchData) {
    List supportList = [];
    for (int i = 0; i < scanData.length - matchData.length; i++) {
      bool isMatch = true;
      for (int j = 0; j < matchData.length; j++) {
        if (scanData[i + j] != matchData[j]) {
          isMatch = false;
          break;
        }
      }

      if (isMatch) {
        for (int j = i; j < scanData.length; j++) {
          supportList.add(scanData[j]);
        }
        break;
      }
    }

    return supportList;
  }

  ///获取用于发送数据的发送接口对象
  SendInterface? getSendInterface(BleBeanInterface bean);

  //获取uuid配置信息
  String getUUIDInfo();

  ///获取兼容名称
  String getSupportName();
}
